package local.eken.gfx.states;

import java.awt.Graphics2D;
import java.awt.event.KeyEvent;

import local.eken.gfx.core.impl.IHandleView;
import local.eken.gfx.states.impl.ViewState;

public class MenuView extends ViewState {

	private static final long serialVersionUID = 4996645454962873708L;
	
	final private static int MENU_NEW_GAME = 0;
	final private static int MENU_LOAD_GAME = 1;
	final private static int MENU_OPTIONS = 2;
	final private static int MENU_EXIT = 3;
	
	private int menuPointer = MENU_NEW_GAME;
	
	public MenuView(IHandleView view) {
		super(view);
	}

	@Override
	public void draw(Graphics2D canvas) {
		
	}

	@Override
	public void handleKey(KeyEvent e) {
		switch(e.getKeyCode()) {
		case KeyEvent.VK_UP:
			this.upInMenu();
			break;
		case KeyEvent.VK_DOWN:
			this.downInMenu();
			break;
		}
	}
	
	private void downInMenu() {
		if(this.menuPointer == MENU_EXIT) {
			this.menuPointer = MENU_NEW_GAME;
		} else {
			this.menuPointer++;
		}
	}
	
	private void upInMenu() {
		if(this.menuPointer == MENU_NEW_GAME) {
			this.menuPointer = MENU_EXIT;
		} else {
			this.menuPointer--;
		}
	}

}
